package week2;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author The Setting sun
 * @create 2021-09-16 16:41
 */
public class work1 {
    public static void main(String[] args) {
        JFrame frame = new JFrame();

        JPanel panel = new JPanel();

        JTextField textField = new JTextField(10);
        JButton button = new JButton("确认");
        JLabel label = new JLabel();

        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                label.setText("姓名：" + textField.getText());
            }
        });

        panel.add(textField);
        panel.add(button);
        panel.add(label);

        frame.add(panel, BorderLayout.NORTH);
        frame.setSize(500, 450);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}
